package sensor;

import java.util.Random;

public class CropSensor extends Sensor {
    private String growthStatus;
    private final Random random = new Random();

    public CropSensor() {
        this.growthStatus = getRandomGrowthStatus();
    }

    public void collectData() {
        growthStatus = getRandomGrowthStatus();
        setSensorData("作物生长状态: " + growthStatus);
    }

    private String getRandomGrowthStatus() {
        String[] statuses = {"良好", "一般", "不佳"};
        return statuses[random.nextInt(statuses.length)];
    }

    @Override
    public void notifyObservers(double data) {
        growthStatus = getRandomGrowthStatus();
        notifyObservers("作物生长状态: " + growthStatus);
    }
}